<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>短网址服务平台</title>
	<meta name="description" content="这是一个 index 页面">
	<meta name="keywords" content="index">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="icon" type="image/png" href="../assets/i/favicon.png">
	<link rel="apple-touch-icon-precomposed" href="../assets/i/app-icon72x72@2x.png">
	<meta name="apple-mobile-web-app-title" content="Amaze UI" />
	<link rel="stylesheet" href="//cdn.staticfile.org/amazeui/2.7.2/css/amazeui.min.css" />
	<link rel="stylesheet" href="../assets/css/admin.css">
	<link rel="stylesheet" href="../assets/css/app.css">
</head>

<body data-type="generalComponents">


	<header class="am-topbar am-topbar-inverse admin-header" id="header">
	</header>
	<div class="tpl-page-container tpl-page-header-fixed">
		<div class="tpl-left-nav tpl-left-nav-hover">
			<div class="tpl-left-nav-title">菜单列表</div>
			<div class="tpl-left-nav-list" id="menu"></div>
		</div>
		<div class="tpl-content-wrapper">
			<ol class="am-breadcrumb">
				<li><a href="#" class="am-icon-home">首页</a></li>
				<li><a href="#">应用管理</a></li>
				<li class="am-active">应用编辑</li>
			</ol>
			<div class="tpl-portlet-components">
				<div class="portlet-title">
					<div class="caption font-green bold">
						<span class="am-icon-code"></span> 编辑应用
					</div>
					<div class="tpl-portlet-input tpl-fz-ml">
						<div class="portlet-input input-small input-inline">
							<div class="input-icon right">
								<i class="am-icon-search"></i> <input type="text"
									class="form-control form-control-solid" placeholder="搜索...">
							</div>
						</div>
					</div>
				</div>
				<div class="tpl-block">
					<div class="am-g">
						<div class="tpl-form-body tpl-form-line">
							<form class="am-form tpl-form-line-form" id="dataForm" onsubmit="return false">
								<div class="am-form-group">
									<label for="user-name" class="am-u-sm-3 am-form-label">应用名称
										<span class="tpl-form-line-small-title">Title</span>
									</label>
									<div class="am-u-sm-9">
										<input name="id" id="dataId" type="hidden" value="" /> <input type="text"
											class="tpl-form-input" id="name" name="name" placeholder="请输入标题文字">
										<small>请填写应用名称</small>
									</div>
								</div>
								<div class="am-form-group" id="statusContainer" style="display: none">
									<label for="user-intro" class="am-u-sm-3 am-form-label">是否启用</label>
									<div class="am-u-sm-9">
										<div class="tpl-switch" onclick="checkOpenPorject()">
											<input name="status" value="1" type="hidden" id="openPorject">
											<input type="checkbox" id="openPorjectCheck" checked
												class="ios-switch bigswitch tpl-switch-btn" />
											<div class="tpl-switch-btn-view">
												<div></div>
											</div>
										</div>

									</div>
								</div>
								<div class="am-form-group">
									<div class="am-u-sm-9 am-u-sm-push-3">
										<button type="button" onclick="save()"
											class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
									</div>
								</div>
							</form>

						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
	<script src="//cdn.staticfile.org/jquery/2.0.3/jquery.min.js"></script>
	<script src="//cdn.staticfile.org/amazeui/2.7.2/js/amazeui.min.js"></script>
	<script src="../assets/js/app.js"></script>
	<script src="../assets/js/loader.js"></script>
	<script src="../assets/js/common.js"></script>
	<script>
		$(function () {
			var id = getQueryVariable('id');
			if (id != null && id != '') {
				loadInfo(id);
			}
		});
		function checkOpenPorject() {
			if ($("#openPorjectCheck").is(':checked')) {
				$("#openPorject").val(1);
			} else {
				$("#openPorject").val(2);
			}
		}
		function loadInfo(id) {
			$.get("/app/info?id=" + id, function (data) {
				if (data.code != 200) {
					return;
				}
				$("#status").val(data.datas.status);
				if (data.datas.status != 1) {
					$("#openPorjectCheck").attr("checked", false);
				}
				$("#name").val(data.datas.name);
				checkOpenPorject();
				if (data.datas.status > 0) {
					$("#statusContainer").show();
				}
				$("#dataId").val(data.datas.id);
			}, 'json');
		}
		function save() {
			$.post("/app/save",
				form2JsonString($("#dataForm")), function (data) {
					if (data.code == 200) {
						history.back();
						return;
					}
					alert(data.msg);
					return;
				}, "json");
		}
	</script>
</body>

</html>